package com.chinasofti.project.web;

import java.util.Date;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.chinasofti.project.common.pageQuery.PageInfo;
import com.chinasofti.project.service.TestService;
import com.chinasofti.project.service.UserQueryInfo;
import com.chinasofti.project.web.common.ControllerBase;
import com.chinasofti.project.web.common.PageQueryForm;

/**
 *
 * @author Lucas
 *
 * @Date 2018年9月27日 下午3:06:25
 *
 */
@Controller
@RequestMapping("test")
public class TestController extends ControllerBase {

	@Autowired
	private TestService testService;

	@RequestMapping("search")
	@ResponseBody
	// http://localhost:8080/breeze/test/search?pageIdx=1&pageSize=10&start=2018-01-01%2000:00:00&end=2018-11-01%2000:00:00&username=%E6%B8%85
	public Object search(TestForm form) {
		PageInfo pageInfo = new PageInfo(form.getPageIdx(), form.getPageSize());
		testService.search(form.getStart(), form.getEnd(), form.getUsername(), pageInfo);
		System.out.println();

		UserQueryInfo userQueryInfo = new UserQueryInfo(form.getPageIdx(), form.getPageSize());
		BeanUtils.copyProperties(form, userQueryInfo);
		testService.search2(userQueryInfo);

		return testService.search2(userQueryInfo);
	}

}

class TestForm extends PageQueryForm {

	private String username;

	private Date start;

	private Date end;

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public Date getStart() {
		return start;
	}

	public void setStart(Date start) {
		this.start = start;
	}

	public Date getEnd() {
		return end;
	}

	public void setEnd(Date end) {
		this.end = end;
	}

}
